package com.friend.campusnotice.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/25.
 */
public class MyPagerAdapter extends FragmentStatePagerAdapter {

    List<Fragment> mFragmentList;
    List<String> title = new ArrayList<>();

    public MyPagerAdapter(FragmentManager fm ,List<Fragment> fragmentList) {
        super(fm);
        this.mFragmentList = fragmentList;
        title.add("联系人");
        title.add("通话记录");
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    //得到每个item
    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }


    // 初始化每个页卡选项
    @Override
    public Object instantiateItem(ViewGroup arg0, int arg1) {
        // TODO Auto-generated method stub
        return super.instantiateItem(arg0, arg1);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        System.out.println( "position Destory" + position);
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
       // return super.getPageTitle(position);
        return title.get(position);
    }
}
